<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "order_info".
 *
 * @property int $id
 * @property int $customer_id 用户id
 * @property string $order_sn 订单号
 * @property string $money_origin 原始金额
 * @property string $money_discount 优惠金额
 * @property string $money_yf 运费
 * @property string $money 实付金额
 * @property string $remark 下单备注
 * @property int $state 订单状态(0：待支付 1：支付成功 2：待退款 3：退款成功 4：退款失败  5：已完成)
 * @property int $status 状态
 * @property int $created_at 创建时间
 */
class OrderInfo extends Base
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'order_info';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['activity_id', 'customer_id','state', 'status', 'created_at'], 'integer'],
            [['money_origin', 'money_discount', 'money_yf', 'money'], 'number'],
            [['order_sn', 'remark'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'customer_id' => 'Customer ID',
            'order_sn' => 'Order SN',
            'money_origin' => 'Money Origin',
            'money_discount' => 'Money Discount',
            'money_yf' => 'Money YF',
            'money' => 'Money',
            'remark' => 'Remark',
            'state' => 'State',
            'status' => 'Status',
            'created_at' => 'Created At',
        ];
    }

    public function getCustomer(){
        return $this->hasOne(Customer::class, ['id' => 'customer_id']);
    }
}
